﻿<UserControl 
    x:ClassModifier="internal"
    x:Class="Smokey.Client.Screens.Applications.ApplicationSearch"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" Loaded="UserControl_Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition
                Height="Auto"/>
            <RowDefinition
                Height="10"/>
            <RowDefinition
                Height="Auto"/>
            <RowDefinition
                Height="15"/>
            <RowDefinition
                Height="Auto"/>
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                Width="126"/>
            <ColumnDefinition
                Width="*"/>
        </Grid.ColumnDefinitions>
        
        <TextBlock
            Grid.ColumnSpan="2"
            Text="APPLICATIONS"
            Style="{StaticResource TitleStyle}"/>
        <Button
            Grid.Row="2"
            Grid.Column="0"
            Content="Add New Application"
            Style="{StaticResource ButtonStyle}"
            Click="AddApplication_Click"/>
        <DataGrid
            x:Name="ApplicationsGrid"
            Grid.Row="4"
            Grid.ColumnSpan="2"
            AutoGenerateColumns="False"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Style="{StaticResource GridStyle}"
            ItemsSource="{Binding Applications}"
            ColumnHeaderStyle="{StaticResource DataGridColumnStyle}">
            <DataGrid.Columns>
                <DataGridHyperlinkColumn
                    Header="Application"
                    Width="*"
                    IsReadOnly="True"
                    Binding="{Binding ApplicationName}">
                    <DataGridHyperlinkColumn.ElementStyle>
                        <Style>
                            <EventSetter Event="Hyperlink.Click"
                                         Handler="ApplicationLink_Click"/>
                        </Style>
                    </DataGridHyperlinkColumn.ElementStyle>
                </DataGridHyperlinkColumn>
                <DataGridTextColumn
                     Header="Last Run"
                     Width="*"
                     IsReadOnly="True"
                     Binding="{Binding LastRunDate}"/>
                <DataGridTextColumn
                    Header="Quality of Tests"
                    Width="*"
                    IsReadOnly="True"
                    Binding="{Binding Quality}"/>
                <DataGridTextColumn
                    Header="Status"
                    Width="*"
                    IsReadOnly="True" 
                    Binding="{Binding StatusDescription}"/>
            </DataGrid.Columns>
        </DataGrid>        
    </Grid>
</UserControl>
